<template>
	<view class="background">
		<navigator open-type="navigateBack" :delta="1" url="">
			<view class="back">
				<i class="iconfont iconzuojiantou"></i>
			</view>
		</navigator>
		<view class="logo logo-margin"></view>

		<view class="flex size-input margin">
			<view class="text">
			</view>
			<input type="number" value="" @input="getiPhone" maxlength="13" placeholder-class="holder" placeholder="请输入邀请码" />
		</view>
		<view class=" btn" @click="next">
			确定
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				iphone: ''
			}
		},
		methods: {
			next() {
				if (this.iphone != '') {
					this.req.request('/regist/inviter', '', 'POST', {
						referrerMobile: this.iphone
					}).then((res) => {
						console.log(res)
						if (res == undefined) {
							uni.showToast({
								title: '响应超时',
								icon: "none",
								mask: true,

							})
						} else if (res.data.code == '500') {
							this.req.toast(res.data.message)
						} else if (res.data.code == '200') {
							uni.showModal({
								title: res.data.data,
								success: (res) => {
									console.log(res)
									if (res.confirm == true) {
										uni.navigateTo({
											url: "../regsiter/regsiter?code=" + this.iphone
										})
									}
								}
							})
						}
					})
				} else {
					uni.showToast({
						title: '邀请人未输入',
						icon: 'none'
					})
				}

			},
			getiPhone(e) {
				this.iphone = e.target.value
				// console.log(e)
			}
		}
	}
</script>

<style>
	.iconfont {
		font-size: 64rpx;
	}

	.code {
		font-weight: bold;
		text-align: center;
		width: 340rpx;
		font-size: 28rpx;
		color: #F0AD4E;
	}

	.border-none {
		border: none;
	}

	.margin {
		margin-top: 60rpx !important;
	}

	.btn {
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		height: 80rpx;
		margin-top: 100rpx;
		background: #F0AD4E;
		color: white;
		line-height: 80rpx;
		border-radius: 20rpx;
	}

	.forget-password {
		width: 180rpx;
		font-size: 28rpx;
		margin-top: 30rpx;
		text-align: center;
		margin-left: calc(100% - 180rpx);
	}

	.holder {
		color: rgb(195, 196, 200);
		font-size: 28rpx;
	}

	.border {
		width: 100%;
		border-bottom: 1px solid rgb(248, 248, 248);
	}

	input {
		/* border-radius: 12rpx; */
		outline: none;
		box-sizing: border-box;
		height: 100%;
		width: 100%;
		padding-left: 20rpx;
		border-bottom: 1px solid rgb(248, 248, 248);
	}

	.size-input {
		line-height: 60rpx;
		width: 100%;
		height: 60rpx;
		margin-top: 120rpx;
	}

	.text {
		font-weight: bold;
		color: rgb(195, 196, 200);
		width: 160rpx;
		font-size: 28rpx;
	}

	.logo-margin {
		margin: 160rpx 0px 0px;
	}
</style>
